
#import "PMGeneral.h"
#import "preferences.h"

@implementation PreferencesManager(General)

//-----------------------------------------------------------
// READ/WRITE
//-----------------------------------------------------------

- readGeneralPrefs;
	{
	[gKeyBindings selectCellWithTag: 
		strcasecmp([NXApp defaultValue:DEFAULT_KEY_BASE],"emacs")?0:1];
	[gKillBehaviour selectCellWithTag:
		[NXApp defaultIntValue:DEFAULT_KILL_BEHAVIOUR]];
	[gChkNewNewsOnActivation setState:
		[NXApp defaultBoolValue:DEFAULT_CHECKNN_ACTIVATION]];
	[gChkNewNewsPeriodically setState:
		([NXApp defaultIntValue:DEFAULT_CHECKNN_PERIOD]>0)];
	[gChkNewNewsInterval setIntValue:
		[NXApp defaultIntValue:DEFAULT_CHECKNN_PERIOD]];
	[gDefaultSavePath setStringValue:
		[NXApp defaultValue:DEFAULT_SAVE_PATH]];
		 
	return self;
	}
	

- writeGeneralPrefs;
	{
	[NXApp setDefault:DEFAULT_KEY_BASE to:
		[[gKeyBindings selectedCell] tag]?"emacs":"none"];
	[NXApp setDefault:DEFAULT_KILL_BEHAVIOUR toInt:
		[[gKillBehaviour selectedCell] tag]];
	[NXApp setDefault:DEFAULT_CHECKNN_ACTIVATION toBool:
		[gChkNewNewsOnActivation state]];
	if([gChkNewNewsPeriodically state])
		[NXApp setDefault:DEFAULT_CHECKNN_PERIOD toInt:[gChkNewNewsInterval intValue]];
	else
		[NXApp setDefault:DEFAULT_CHECKNN_PERIOD toInt:0];
	[NXApp setDefault:DEFAULT_SAVE_PATH to:[gDefaultSavePath stringValue]];
	
	return self;
	}


//-----------------------------------------------------------
// THAT'S IT
//-----------------------------------------------------------

@end
